package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.User;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {

  /**
   * 根据openid查询用户
   *
   * @param openid
   * @return
   */
  @Select("select * from user where openid = #{opinid}")
  User getByOpenid(String openid);

  /**
   * 插入用户数据
   *
   * @param user
   */
  @Insert("insert into user(openid, name, phone, sex, id_number, avatar, create_time) VALUES " +
          " (#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
  @Options(useGeneratedKeys = true, keyProperty = "id")
  void insert(User user);



  /**
   * 根据id查询用户
   * @param id
   * @return
   */
  @Select("select * from user where id = #{id}")
  User getById(Long id);


  /**
   * 统计指定时间区间内的用户数量(总用户量、新增用户量)
   * @param map
   * @return
   */
    Integer countByMap(Map map);
}